﻿<UserControl x:Class="Songhay.Silverlight.BiggestBox.AdditionalSamplesPart.Views.SlideshowSample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:galaEx="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL5"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:toolkitLayout="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
    xmlns:vc="clr-namespace:Songhay.ValueConverters;assembly=Songhay.Silverlight"
    xmlns:vm="clr-namespace:Songhay.Silverlight.BiggestBox.AdditionalSamplesPart.ViewModels"
    Tag="Slideshow with TransitioningContentControl Sample"
    Width="512" Height="400">
    <UserControl.Resources>
        <vc:InverseBooleanConverter x:Key="InverseBooleanConverter" />
        <vc:LocationToImageSourceConverter x:Key="LocationToImageSourceConverter" />
        <vm:SlideshowSampleViewModel x:Key="SlideshowSampleViewModelDataSource" d:IsDataSource="True" />
    </UserControl.Resources>
    <UserControl.DataContext>
        <Binding Source="{StaticResource SlideshowSampleViewModelDataSource}" />
    </UserControl.DataContext>
    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <galaEx:EventToCommand
                Command="{Binding ViewLoadedCommand, Mode=OneWay}"
                />
        </i:EventTrigger>
        <i:EventTrigger EventName="Unloaded">
            <galaEx:EventToCommand
                Command="{Binding ViewUnloadedCommand, Mode=OneWay}"
                />
        </i:EventTrigger>
    </i:Interaction.Triggers>
    <StackPanel
        HorizontalAlignment="Center" VerticalAlignment="Top">
        <toolkitLayout:TransitioningContentControl
            Content="{Binding ElementName=Thumbs, Path=SelectedValue}">
            <toolkitLayout:TransitioningContentControl.ContentTemplate>
                <DataTemplate>
                    <Image
                        Source="{Binding}"
                        Width="400" Height="300"
                        />
                </DataTemplate>
            </toolkitLayout:TransitioningContentControl.ContentTemplate>
        </toolkitLayout:TransitioningContentControl>
        <ListBox x:Name="Thumbs"
            Background="Transparent"
            IsEnabled="{Binding IsDoingSlidesTick, Converter={StaticResource InverseBooleanConverter}}"
            ItemsSource="{Binding SlidesCollection}"
            SelectedIndex="{Binding SlidesSelectedIndex, Mode=TwoWay}"
            Width="Auto" Height="70">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <StackPanel
                        Orientation="Horizontal"
                        />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image
                        Cursor="Hand"
                        HorizontalAlignment="Center" VerticalAlignment="Center"
                        Source="{Binding Path=., Converter={StaticResource LocationToImageSourceConverter}}"
                        Width="64" Height="48"
                        />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox >
        <ToggleButton
            Command="{Binding SlidesToggleCommand}"
            Cursor="Hand"
            Content="Toggle Slideshow"
            IsChecked="{Binding IsDoingSlidesTick, Mode=TwoWay}"
            />
    </StackPanel>
</UserControl>
